﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.ChangeLog;
using Model.RF.ChangeLog;

namespace DAL.RF.ChangeLog
{
    public class RepairConfig_ChangeLog : BaseRepository_DT<RepairConfig_ChangeLogInfo>, IRepairConfig_ChangeLog
    {
        #region 静态变量部分
        private const string PARM_ID = "@ID";
        private const string PARM_RECORDTIME = "@RecordTime";
        private const string PARM_USERID = "@UserID";
        private const string PARM_IPADDRESS = "@IPAddress";
        private const string PARM_REPAIRPATH = "@RepairPath";
        private const string PARM_OLDSTATUS = "@OldStatus";
        private const string PARM_NEWSTATUS = "@NewStatus";
        #endregion

        #region 数据检索部分
        public IList<RepairConfig_ChangeLogInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public RepairConfig_ChangeLogInfo LoadEntity<T1>(T1 id)
        {
            return null;
        }

        public IList<RepairConfig_ChangeLogInfo> RepairConfig_ChangeLog_GetbyDT(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return ExcuteSqlToGetEntities("RepairConfig_Changelog_selectbyDT", parms);
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override RepairConfig_ChangeLogInfo GetEntityRecord(SqlDataReader rdr)
        {
            RepairConfig_ChangeLogInfo pro = new RepairConfig_ChangeLogInfo()
            {
                ID = rdr.GetInt32(0),
                RecordTime = rdr.GetDateTime(1),
                UserID = rdr.GetValue(2).ToString(),
                IPAddress = rdr.GetValue(3).ToString(),
                RepairPath = rdr.GetValue(4).ToString(),
                OldStatus = rdr.GetValue(5).ToString(),
                NewStatus = rdr.GetValue(6).ToString()
            };
            return pro;
        }

        public override RepairConfig_ChangeLogInfo GetEntityRecord()
        {
            RepairConfig_ChangeLogInfo pro = new RepairConfig_ChangeLogInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "RepairConfig_Changelog_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_ID, SqlDbType.Int, 4),
					new SqlParameter(PARM_RECORDTIME, SqlDbType.DateTime, 8),
                    new SqlParameter(PARM_USERID, SqlDbType.NVarChar, 10),
					new SqlParameter(PARM_IPADDRESS, SqlDbType.NVarChar , 20),
                    new SqlParameter(PARM_REPAIRPATH,SqlDbType.NVarChar,50),
                    new SqlParameter(PARM_OLDSTATUS,SqlDbType.NVarChar,500),
                    new SqlParameter(PARM_NEWSTATUS,SqlDbType.NVarChar,500)
                };
            return parms;
        }

        public override void SetParameters(RepairConfig_ChangeLogInfo entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = entity.ID;
            Parms[1].Value = entity.RecordTime;
            Parms[2].Value = entity.UserID;
            Parms[3].Value = entity.IPAddress;
            Parms[4].Value = entity.RepairPath;
            Parms[5].Value = entity.OldStatus;
            Parms[6].Value = entity.NewStatus;
        }
        #endregion
    }
}
